import { ChunkLib } from "../ChunkLib";
import ShaderLib from "../ShaderLib";

export default class RippleWallShader {
  public static getVertexShader() {
    return ShaderLib.getDefaultVertexShader();
  }

  public static getFragmentShader() {
    const shader = `
        #include <common>
        #include <fog_pars_fragment>
        #include <logdepthbuf_pars_fragment>  
        varying vec2 uvTexcoord;
        uniform float time;        
        uniform float height;
        uniform float altitude;
        uniform vec3 v_color;
        uniform float hiz;
        uniform float num;
        #define PIValue 3.14159265359

        ${ChunkLib.snow_pars_fragment}
        void main(){
     
          ${ChunkLib.precision_low}      
          vec2 uv = uvTexcoord;
          vec4 fragColor = vec4(0.);

          float sin = sin((uv.y+0.5 - time)*PIValue*(2.0*num));

          float high = 0.9;
          float medium = 0.4;

          if (sin > high) {
            fragColor = vec4(mix(vec3(.8, 1., 1.), v_color.rgb, (1. - sin) / (1. - high)), 1.);
           } else if(sin > medium) {
             fragColor = vec4(v_color.rgb, mix(1., 0.15, 1.-(sin - medium) / (high - medium)));
           } else {
             fragColor = vec4(v_color.rgb, 0.15);
           }
           vec3 fade = vec3(smoothstep(0.7, 0.4, clamp(-(1. - uv.y) * .25 + .8, 0., .75)), v_color.g, v_color.b);
           fragColor += vec4(fade, fade.x * 2.0);
           ${ChunkLib.snow_fragment}
           fragColor.a *= (1. - uv.y);

          gl_FragColor = fragColor;
          #include <fog_fragment>
        }`
    return shader;
  }

}





